package com.huping.controller;

import com.alibaba.fastjson.JSONObject;
import com.huping.pojo.Result;
import com.huping.service.OJService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
public class OJController {

    @Autowired
    private OJService ojService;


    @PostMapping("/OJ/teacher-update")
    public Result teacherUpdate(@RequestBody JSONObject param){
        return ojService.teacherUpdate(param);
    }

    @PostMapping("/OJ/student-update")
    public Result studentUpdate(@RequestParam("gradeId") Integer gradeId, @RequestParam("code") String code,@RequestParam("codeType") String codeType){
        return ojService.studentUpdate(gradeId,code,codeType);
    }

    @PostMapping("/OJ/student-submit")
    public Result studentSubmit(@RequestParam("gradeId") Integer gradeId, @RequestParam("code") String code,@RequestParam("codeType") String codeType) throws IOException, InterruptedException {
        return ojService.studentSubmit(gradeId,code, codeType);
    }

}
